<!--
 * @Description: 
 * @Author: charles
 * @Date: 2020-11-03 16:49:08
 * @LastEditors: charles
 * @LastEditTime: 2021-08-01 14:07:33
-->
<template>
  <div class="applyQuery">
    <div class="query">
      手机号
      <el-input
        v-model="telephone"
        size="small"
        style="width: 200px; margin: 0 10px"
      ></el-input>
      <el-button size="small" @click="query()">搜索</el-button>
      <div class="toApply">
        暂无报名信息，
        <el-button type="text" @click="toApply()">去报名</el-button>
      </div>
    </div>
    <div id="wrapper">
      <div class="title">报名的游学项目</div>
      <div
        class="project"
        v-for="project in projects"
        :key="project.id"
      >
        <div class="left">
          <img width="100%" :src="project.project.figure" alt="" />
        </div>
        <div class="right">
          <div class="name">
            <strong style="font-size:20px">{{ project.project.name }}</strong>
          </div>
          <div class="time1">
            <strong>时间：</strong>
            {{ project.project.beginTime | fmtDate }} ~
            {{ project.project.endTime | fmtDate }}
          </div>
          <div class="money" v-if="project.project.projectMoney != null">
            <strong>费用：</strong>
            {{ project.project.projectMoney }}
          </div>
          <div class="money" v-if="project.project.projectMoney == null">
            <strong>费用：</strong>
            无
          </div>
          <div class="time2">
            <strong>报名时间：</strong>
            {{ project.insertTime | fmtDate }}
          </div>
          <div class="status" v-if="project.status == '未确认'">
            <strong>报名状态：</strong>
            <span style="color:red; background-color:pink; padding:0.3em; border-radius:5px">{{project.status}}</span>
          </div>
          <div class="status" v-if="project.status == '已确认'">
            <strong>报名状态：</strong>
            <span style="color:#057E39; background-color:#74E5B4; padding:0.3em; border-radius:5px">{{project.status}}</span>
          </div>
          <div class="introduce">
            <strong>简介：</strong>
            {{project.project.introduce}}
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import { get } from "../utils/request";
export default {
  data() {
    return {
      telephone: "",
      projects: [],
    };
  },
  methods: {
    query() {
      get("/index/apply/query", { telephone: this.telephone }).then((res) => {
        // console.log(res);
        var wrapper = document.getElementById("wrapper");
        var toApply = document.getElementsByClassName("toApply")[0];
        if (res.status == 200) {
          wrapper.style.display = "block";
          toApply.style.display = "none";
          this.projects = res.data;
        }
      });
    },
  },
};
</script>
<style lang="scss" scoped>
.query {
  width: 400px;
  margin: 0 auto;
  margin-top: 50px;
  margin-bottom: 10px;
  text-align: center;
}
#wrapper {
  display: none;
  width: 1200px;
  margin: 0 auto;
  .title {
    font-size: 20px;
    line-height: 4em;
    border-bottom: 1px solid #f4f4f4;
  }
  .project {
    display: flex;
    padding: 1em 0;
    border-bottom: 1px solid #f4f4f4;
    .left {
      width: 300px;
      height: 200px;
      background-color: #f4f4f4;
      border-radius: 5px;
      overflow: hidden;
    }
    .right {
      flex: 1;
      // background-color: teal;
      padding: 0 2em;
      .name {
        font-weight: 500;
        font-size: 15px;
      }
      .time1 {
        margin: 0.8em 0;
      }
      .time2 {
        margin: 0.8em 0;
      }
      .introduce{
        margin: 0.8em 0;
      }
    }
  }
}
</style>